/**
 * 
 */
package com.local.runnable.MultTask;

/**
 * @author Administrator
 *
 */
public class Task {
	public static final int READY = 0;
	public static final int RUNNING = 1;
	public static final int FINISHED = 2;

	private int status;// 声明一个任务的自有业务含义的变量，用于标识任
	private int taskId;

	public int getStatus() {
		return status;
	}
	public void setStatus(int status) {
		this.status = status;
	}
	public int getTaskId() {
		return taskId;
	}
	public void setTaskId(int taskId) {
		this.taskId = taskId;
	}
	
	public Task(int taskId) {//构造函数
		this.status = READY;
		this.taskId = taskId;
		}
	public void execute() {
		// 设置状态为运行中
		setStatus(Task.RUNNING);
		System.out.println("当前线程 ID 是：" + Thread.currentThread().getName() + " | 任务 ID 是：" + this.taskId);
		// 附加一个延时
		try {
			Thread.sleep(1000);
		} catch (InterruptedException e) {
			e.printStackTrace();
		}
		// 执行完成，改状态为完成
		setStatus(FINISHED);
	}

}
